//
//  YYYNavigationButton.swift
//  HotNews
//
//  Created by YYY on 2017/10/16.
//  Copyright © 2017年 成品家（北京）网路科技有限公司. All rights reserved.
//

import UIKit

class YYYNavigationButton: UIButton {
    //重载构造函数
    init(title: String?)
    {
        super.init(frame: CGRect())

        if title == nil
        {
            setTitle("首页", for: .normal)
        }
        else
        {
            setTitle(title! + "   ", for: .normal)
            //设置图片
//            setImage(UIImage(named: "navigationbar_arrow_down"), for: .normal)
//            setImage(UIImage(named: "navigationbar_arrow_up"), for: .selected)
        }
        //设置文字字体颜色和大小
        setTitleColor(UIColor.darkGray, for: .normal)
        titleLabel?.font = UIFont.boldSystemFont(ofSize: 17)
        
        //设置大小
        sizeToFit()
        
        guard let imageView = imageView,
              let titleLabel = titleLabel else {
                return
        }

        titleEdgeInsets = UIEdgeInsets(top: 0, left: -imageView.bounds.width, bottom: 0, right: 0)
        imageEdgeInsets = UIEdgeInsets(top: 0, left: titleLabel.bounds.width, bottom: 0, right: 0)
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
}
